package pharao.client.views.game.player;

import hmvc4gwt.client.event.IHmvcEvent;
import hmvc4gwt.framework.client.model.GuiModel;
import pharao.client.dto.UserDTO;
import pharao.client.views.game.player.events.GetUserEvent;
import pharao.client.views.game.player.events.SetUserEvent;

public class PlayerModel extends GuiModel {

	/**
	 * enthält den User des Spiels
	 */
	private UserDTO userDTO;
	
	public PlayerModel(UserDTO userDTO) {
		setUserDTO(userDTO);
	}

	public void init() {
		getController().register(GetUserEvent.class, this);
	}

	private UserDTO getUserDTO() {
		return userDTO;
	}

	public void handleEvent(IHmvcEvent event) {
		if (event instanceof GetUserEvent) {
			getController().fireEvent(new SetUserEvent(getUserDTO()), true, false, false);
		}
	}

	private void setUserDTO(UserDTO userDTO) {
		this.userDTO = userDTO;
	}

	public void terminate() {
		// TODO Auto-generated method stub
		
	}

}
